import time
from concurrent.futures import ProcessPoolExecutor


def count(count_to):
    start = time.time()
    counter = 0
    while counter < count_to:
        counter += 1
    end = time.time()
    print(f"计算{count_to}一共花费时间为：{end - start}s")
    return counter


if __name__ == '__main__':
    with ProcessPoolExecutor() as process_pool:
        numbers = [1, 3, 5, 22, 100000000]
        # 它是有序的，输出顺序与numbers保持一致
        for result in process_pool.map(count, numbers):
            print(result)
